package sort1;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class FlowBean implements WritableComparable<FlowBean> {
   //private String Site;//网址
    //private String Category;//类别
    private long UniqueVisitors;//浏览量
   //private long Reach;//增加
    //private String PageViews;//总流量
   // private String HasAdvertising;//有无广告
   // private String InEnglish;//是否用英语
   // private String TLD;//域名





    public FlowBean() {
        super();
    }

   // public FlowBean(long upFlow,long downFlow) {
    //this.upFlow = upFlow;
      //  this.downFlow=downFlow;
      //  sumFlow=upFlow + downFlow;

    //}




    //比较
    @Override
    public int compareTo(FlowBean bean) {

        int result;

        //核心比较条件判断
        if(UniqueVisitors> bean.getUniqueVisitors()){        //倒序
            result=-1;
        }else if (UniqueVisitors< bean.getUniqueVisitors()){
            result=1;
        }else {
            result=0;
        }
        return result;
    }
//序列化
    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(UniqueVisitors);
       // out.writeLong(Reach);
      //  out.writeChars(PageViews);
      //  out.writeChars(Category);
       // out.writeChars(HasAdvertising);
       // out.writeChars(InEnglish);
       // out.writeChars(TLD);
       // out.writeChars(Site);
    }
//反序列化
    @Override
    public void readFields(DataInput in) throws IOException {
       //  Site=in.readLine();//网址
       // Category=in.readLine();//目录
        UniqueVisitors=in.readLong();//浏览量
        // Reach= in.readLong();//增加
       //  PageViews=in.readLine();//总流量
       // HasAdvertising=in.readLine();//有无广告
       // InEnglish=in.readLine();//是否用英语
      //  TLD=in.readLine();//域名

    }

    public long getUniqueVisitors() {
        return UniqueVisitors;
    }

    public void setUniqueVisitors(long uniqueVisitors) {
       this.UniqueVisitors = uniqueVisitors;
    }

    @Override
    public String toString() {
        return UniqueVisitors+"";
    }
}
